#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "mylog.h"



int do_outputfile_option(int params_num,const char *params[])
{
	config_info* config=get_config();
	strncpy(config->output_file,params[0],strlen(params[0])+1);
	return 0;
}

int do_defaultlevel_option(int params_num,const char *params[])
{
	config_info* config=get_config();
	config->default_level=make_level_to_int((params[0]));
	return 0;
}

int do_format_option(int params_num,const char *params[])
{
	int i;
	config_info* config=get_config();
	for(i=0;i<params_num;i++)
		config->format[i]=make_format_to_int(params[i]);
	return 0;
}

int do_maxsize_option(int params_num,const char *params[])
{
  config_info* config=get_config();
  config->max_size=atol(params[0]);
  return 0;
}

int do_savelog_option(int params_num,const char*params[])
{
	config_info* config=get_config();
	if(strncmp(params[0],"TRUE",4)==0) config->save_log=1; // TOFIX params may be NULL!
	else if(strncmp(params[0],"FALSE",5)==0) config->save_log=0;
	return 0;
}

int init_regist()
{

	regist_option("OutputFile",do_outputfile_option);
	regist_option("DefaultLevel",do_defaultlevel_option);
	regist_option("Format",do_format_option);
	regist_option("MaxSize",do_maxsize_option);
	regist_option("SaveLog",do_savelog_option);
	return 0;
}


	
